package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;

import static java.lang.String.format;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/23/13
 * Time: 1:27 PM
 * To change this template use File | Settings | File Templates.
 */
public class MovieLibrary {
    private  PrintStream printSteam;
    private  HashMap<String, Movie> movies;

    public MovieLibrary(HashMap<String,Movie> movies, PrintStream printStream) {
        this.movies = movies;
        this.printSteam = printStream;
    }

    public void showHeader() {
       printSteam.println(format("%-15s %-4s %-20s %-3s", "Movie", "Year", "Director", "Rating"));
    }


    public void showMovies() {
        for(Map.Entry<String, Movie> movie: movies.entrySet()){
            printSteam.println(movie.getValue());
        }
    }
}
